import { Router, createRouter, createWebHashHistory } from 'vue-router'
import { routes } from 'vue-router/auto-routes'
import { registryRouterChannel } from './channel'
// const { pushStack } = useAppRouter()
const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      // 重定向
      // redirect: '/layout/home'
      // redirect: '/layout/profile'
      redirect: '/stacks/sign-in'
    },
    ...routes
  ]
}) as Router

const { notify } = registryRouterChannel(router)
console.log("router=>", router)
// , from, next
router.beforeEach((to) => {
  // console.log("beforeEach", to.path)
  notify(to.fullPath)
})

export default router
